package clt.com.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import clt.com.mapper.EnrollMapper;
import clt.com.object.Enroll;
import clt.com.service.IEnrollService;
import clt.com.service.common.impl.BaseServiceImpl;

@Service("enrollService")
public class EnrollServiceImpl extends BaseServiceImpl implements IEnrollService{
	@Autowired
	private EnrollMapper enrollMapper;
	/**
	 * 
	 * @Title  报名列表查询
	 * @Description:  queryEnrollList
	 * @param: @param compay
	 * @param: @return
	 * @return 
	 * @throws
	 * @author zzx
	 * @Date 2018年8月15日
	 */
	public Map<String,Object> queryEnrollList(Map<String,String> map){
		List<Map<String,String>> list = enrollMapper.queryEnrollList(map);
		int count = enrollMapper.queryEnrollListCount(map);
		Map<String,Object> bean = new HashMap<>();
		bean.put("total", Integer.toString(count));
		Map<String,Object> map1 = new HashMap<>();
		map1.put("beans", list);
		map1.put("bean", bean);
		map1.put("busiCode", "");
    	map1.put("returnCode", "0");
    	map1.put("returnMessage", "");
    	map1.put("object", "");
    	map1.put("busiCode", ""); 
		return map1;
	}
	/**
	 * 
	 * @Title  报名新增
	 * @Description:  saveEnrollInfo
	 * @param: @param enroll
	 * @param: @return
	 * @return 
	 * @throws
	 * @author zzx
	 * @Date 2018年8月15日
 */
	public Map<String,Object> saveEnrollInfo(Enroll enroll) throws Exception{
		String investId = getSequence("t_pt_enroll");		
		enroll.setEnrollId(investId);
		int flag = enrollMapper.saveEnrollInfo(enroll);
		Map<String,Object> bean = new HashMap<>();
    	if(flag != 1){
    		bean.put("rtnCd", "9999");
    	}else {
    		bean.put("rtnCd", "00");
    	}
    	Map<String,Object> map1 = new HashMap<>();
		map1.put("bean", bean);
		map1.put("busiCode", "");
    	map1.put("returnCode", "0");
    	map1.put("returnMessage", "");
    	map1.put("object", "");
    	map1.put("busiCode", "");		
    	return map1;
	}
	/**
		 * 
		 * @Title  报名修改
		 * @Description:  updateEnrollInfo
		 * @param: @param enroll
		 * @param: @return
		 * @return 
		 * @throws
		 * @author zzx
		 * @Date 2018年8月15日
	 */
	public Map<String,Object> updateEnrollInfo(Enroll enroll) throws Exception{
		int flag = enrollMapper.updateEnrollInfo(enroll);
		Map<String,Object> bean = new HashMap<>();
    	if(flag != 1){
    		bean.put("rtnCd", "9999");
    	}else {
    		bean.put("rtnCd", "00");
    	}
    	Map<String,Object> map1 = new HashMap<>();
		map1.put("bean", bean);
		map1.put("busiCode", "");
    	map1.put("returnCode", "0");
    	map1.put("returnMessage", "");
    	map1.put("object", "");
    	map1.put("busiCode", "");		
    	return map1;
	}
	/**
	 * 
	 * @Title  报名人员详情查询
	 * @Description:  queryEnrollDtlById
	 * @param: @param compay
	 * @param: @return
	 * @return 
	 * @throws
	 * @author zzx
	 * @Date 2018年8月21日
	 */
	public Map<String,Object> queryEnrollDtlById(Map<String,String> map){
		Map<String,String> bean = enrollMapper.queryEnrollDtlById(map);
		Map<String,Object> map1 = new HashMap<>();
		map1.put("beans", null);
		map1.put("bean", bean);
		map1.put("busiCode", "");
    	map1.put("returnCode", "0");
    	map1.put("returnMessage", "");
    	map1.put("object", "");
    	map1.put("busiCode", ""); 
		return map1;
	}
	/**
	 * 
	 * @Title  报名人员删除
	 * @Description:  delEnrollInfoById
	 * @param: @param enroll
	 * @param: @return
	 * @return 
	 * @throws
	 * @author zzx
	 * @Date 2018年8月21日
	 */
	public Map<String,Object> delEnrollInfoById(Enroll enroll){
		int count = enrollMapper.delEnrollInfoById(enroll);
		Map<String,Object> map1 = new HashMap<>();
		map1.put("beans", "");
		map1.put("bean", "");
		map1.put("busiCode", "");
    	map1.put("returnCode", "0");
    	map1.put("returnMessage", "");
    	map1.put("object", "");
    	map1.put("busiCode", ""); 
		return map1;
	}
}
